package com.tony.study.designMode.DM2_抽象工厂;

/**
 * Created with IntelliJ IDEA.
 *
 * @Title: AFactoryAllTest
 * @Auther: 皮蛋布丁
 * @Date: 2021/11/30/15:57
 * @Description:
 */
public class AFactoryAllTest {
    public static void main(String[] args) {
        LenovoFactory01 lenovoFactory01 = new LenovoFactory01();
        ProductKeyBord keyBord01 = lenovoFactory01.createKeyBoard();
        keyBord01.productKeyBoard("M550", "黑色");
        ProductMouse mouse01 = lenovoFactory01.createMouse();
        mouse01.productMouse("M590", "有线");

        System.out.println("==============================");

        LenovoFactory02 lenovoFactory02 = new LenovoFactory02();
        ProductKeyBord keyBord02 = lenovoFactory02.createKeyBoard();
        keyBord02.productKeyBoard("M550", "白色");
        ProductMouse mouse02 = lenovoFactory02.createMouse();
        mouse02.productMouse("M590", "无线");
    }
}
//键盘工厂
interface ProductKeyBord {
    void productKeyBoard(String name,String color);
}
//鼠标工厂
interface ProductMouse {
    void productMouse(String name,String type);
}
//电脑抽象工厂
abstract interface AComputerFactory {
    ProductKeyBord createKeyBoard();
    ProductMouse createMouse();
}
//雷柏键盘生产商
class LeiBoKeyBoard implements ProductKeyBord{
    @Override
    public void productKeyBoard(String name,String color) {
        System.out.println("雷柏键盘--"+name+","+color);
    }
}
//罗技键盘生产商
class LuoJiKeyBoard implements ProductKeyBord {
    @Override
    public void productKeyBoard(String name,String color) {
        System.out.println("逻辑键盘--"+name+","+color);
    }
}
//雷柏鼠标生产商
class LeiBoMouse implements ProductMouse {
    @Override
    public void productMouse(String name,String type) {
        System.out.println("雷柏键盘--"+name+","+type);
    }
}
//罗技鼠标生产商
class LuoJiMouse implements ProductMouse {
    @Override
    public void productMouse(String name,String type) {
        System.out.println("罗技鼠标"+name+","+type);
    }
}
//电脑生产商1
class LenovoFactory01 implements AComputerFactory {
    @Override
    public ProductKeyBord createKeyBoard(){
        return new LeiBoKeyBoard();
    }
    @Override
    public ProductMouse createMouse() {
        return new LeiBoMouse();
    }
}
class LenovoFactory02 implements AComputerFactory {
    @Override
    public ProductKeyBord createKeyBoard() {
        return new LuoJiKeyBoard();
    }
    @Override
    public ProductMouse createMouse() {
        return new LuoJiMouse();
    }
}
